home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / MCASM.RAR / MC_ASM.EXE / WROX_ASM / CH12 / EFFECTS / PALEFF.CPP < prev    next >
C/C++ Source or Header  |  1994-11-14  |  1KB  |  101 lines

  1. #include <dos.h>
  2. #include <mem.h>
  3. #include <stdlib.h>
  4. #include <conio.h>
  5.  
  6. #include "graph.h"
  7. #include "paleff.h"
  8.  
  9. VGApalette Pal;
  10.  
  11. int _r,_g,_b,r0,g0,b0;
  12. const Cyclelen = 20;
  13. const PaletteLen = 201;
  14. const MaxDer = 25;
  15.  
  16. void colorwheel(int first,int count,void *Pal)
  17. {
  18. asm {
  19.         cld
  20.         push ds
  21.         push di
  22.         push si
  23.         les di,Pal
  24.         mov ax,es
  25.         mov ds,ax
  26.         mov ax,first
  27.         add ax,ax
  28.         add ax,first
  29.         add di,ax
  30.         mov si,di
  31.         mov bx,[si]
  32.         mov dl,[si+2]
  33.         mov cx,count
  34.         add cx,cx
  35.         add cx,count
  36.         add si,3
  37.         shr cx,1
  38.         rep movsw
  39.         shl cl,1
  40.         rep movsb
  41.         mov [di],bx
  42.         mov [di+2],dl
  43.         pop si
  44.         pop di
  45.         pop ds
  46. }
  47. }
  48.  
  49. void colwheeldemo1(void* v)
  50. {
  51. int i,j;
  52. memset(Pal,768,0);
  53. for(i=127;i<=191;i++)
  54. {
  55.     Pal[i].r=60;
  56.     Pal[i].b=0;
  57.     Pal[i].g=i-127;
  58. }
  59.  
  60. for(i=0;i<=199;i++)
  61.     for(j=0;j<=319;j++) *&MixBuffer(v)[i][j]=random(64)+127;
  62.  
  63. do
  64. {
  65. setDACblock(0,191,Pal);
  66. colorwheel(127,64,Pal);
  67. } while (!kbhit());
  68. }
  69.  
  70. void colwheeldemo2(void* v)
  71. {
  72. int i,j,k,l;
  73. memset(Pal,768,0);
  74. for(i=127;i<=191;i++)
  75. {
  76.     Pal[i].r=60;
  77.     Pal[i].b=0;
  78.     Pal[i].g=i-127;
  79. }
  80. for(i=192;i<=252;i++)
  81. {
  82.     Pal[i].r=60;
  83.     Pal[i].b=0;
  84.     Pal[i].g=i-192;
  85. }
  86.  
  87. for(l=0;l<=19;l++)
  88. for(i=0;i<=19;i++)
  89. for(j=l*10;j<=l*10+9;j++)
  90. for(k=i*16;k<=i*16+15;k++)
  91. if ((l % 2) == 0) *&MixBuffer(v)[j][k]=random(63)+i*10;
  92.         else *&MixBuffer(v)[j][k]=252-(random(63)+i*10);
  93.  
  94. do
  95. {
  96.     setDACblock(0,246,Pal);
  97.     colorwheel(10,246,Pal);
  98.     delay(10);
  99. } while (!kbhit());
  100. }
  101.